//
//  main.m
//  OC6_省市区对象做法
//
//  Created by dllo on 15/11/2.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "Province.h"
#import "City.h"

int main(int argc, const char * argv[]) {

    NSString *path = @"/Users/dllo/Desktop/省市区/area.txt";
    NSString *str = [NSString stringWithContentsOfFile:path encoding:NSUTF8StringEncoding error:nil];
    NSArray *arr = [str componentsSeparatedByString:@"\n"];
//    NSLog(@"%@", str);
    Province *province = [[Province alloc] init];
    City *city = [[City alloc] init];
    
    for (NSInteger i = 0; i < arr.count; i++) {
        NSString *temp = [arr objectAtIndex:i];
        if (![temp hasPrefix:@" "]) {
            [province setProvinceName:temp];
            [province setCityArr:[NSMutableArray array]];
        } else if (![temp hasPrefix:@"   "]) {
            [city setCityName:temp];
            [city setAreaArr:[NSMutableArray array]];
        } else {
            [city setAreaName:temp];
        }
    }
    
    
    for (NSInteger i = 0; i < [city areaArr].count; i++) {
        if ([[city areaName] isEqualToString:@"  大连市 38"]) {
            NSLog(@"%@", [city areaArr]);
        }
    }

    
    
    
    return 0;
}
